From 80ffc501c431ad777100180bccdbfaef9f954f91 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc" Date: Fri, 4 Oct 2024 20:03:14 -0500 Subject: [PATCH] Test outside of loop --- src/pgwui_sql/views/sql.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/pgwui_sql/views/sql.py b/src/pgwui_sql/views/sql.py index 2c6b665..52e531c 100644 --- a/src/pgwui_sql/views/sql.py +++ b/src/pgwui_sql/views/sql.py @@ -337,24 +337,23 @@ class SQLResultsHandler(pgwui_core.core.SessionDBHandler): csv_writer = self.write_sql() nextset = True - download_as = self.uf['download_as'] - stmt_no = 1 - while nextset is True: - if download_as == MANY_FILES_VALUE: + if self.uf['download_as'] == MANY_FILES_VALUE: + stmt_no = 1 + while nextset is True: with zipfile.Path( self.zip_fd, at=self.zip_at_pathname(f'stmt{stmt_no}.txt') ).open(mode='w', newline='') as fd: self.write_resultset( cur, self.make_csv_writer(fd), null_rep) + nextset = cur.nextset() stmt_no += 1 - else: + self.zip_fd.close() + else: + while nextset is True: self.write_resultset(cur, csv_writer, null_rep) + nextset = cur.nextset() - nextset = cur.nextset() - - if download_as == MANY_FILES_VALUE: - self.zip_fd.close() self.tfile.seek(0) def make_sql_results(self, cur): -- 2.34.1